package com.huchao.www.dao;

import com.huchao.www.pojo.LoginLog;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;

/**
 * @Description:
 * @BelongsProject: springMVC
 * @BelongsPackage: com.huchao.www.dao
 * @Author: 亖思
 * @CreateTime: 2022/12/8 20:39
 * @Version: 1.0
 */
@Mapper
public interface LoginLogMapper {

    /**
     * 〈新增日志〉
     *
     * @param log:日志实体
     * @Author: 亖思
     * @Date: 2022/12/12 14:24
     **/
    @Insert("insert into login_log(input_login_name,client_ip,login_time,login_result) values (#{inputLoginName},#{clientIp},#{loginTime},#{loginResult} = true)")
    void insertLogInfo(LoginLog log);

    /**
     * 〈定时删除不用的数据--时间在ddl之前且登录成功的记录〉
     * @Author: 亖思
     * @Date: 2023/3/22 20:37
     * @param ddl: 截至时间
     * @return: boolean
     **/
    @Delete("DELETE FROM login_log WHERE login_result = 1 AND login_time < #{ddl}")
    boolean updateLogInfo(@Param("ddl") LocalDateTime ddl);
}
